<template>
  <div class="vue-box sbot sbot-fluid">
    <!-- 参数栏 -->
    <div class="c-panel">
      <el-form :inline="true">
        <!-- 表单 -->
        <sa-item v-model="m.avatar" type="img" name="用户头像" br />
        <sa-item v-model="m.nickName" type="text" name="用户昵称" br />
        <sa-item v-model="m.name" type="text" name="用户账户" br />
        <sa-item v-model="m.pwd" type="password" name="用户密码" br />
        <sa-item v-model="m.surePwd" type="password" name="确认密码" br />
        <sa-item v-model="m.phone" type="text" name="联系方式" br />
        <sa-item v-model="m.email" type="text" name="邮箱" br />

        <sa-item v-model="m.birth" type="datetime" name="出生日期" br />
        <sa-item v-model="m.height" type="text" name="身高(/cm)" br />
        <sa-item v-model="m.weight" type="text" name="体重(/kg)" br />
        <sa-item v-model="m.blood" type="enum" name="血型(xo)" jtype="3" :jv="dims.BLOOD_TYPE" br />
        <sa-item v-model="m.sex" type="enum" name="用户性别" jtype="3" :jv="dims.GENDER" br />
        <sa-item v-model="m.status" type="enum" jtype="3" :jv="dims.YES_OR_NO" name="启用状态" brbr />
        <sa-item v-model="m.note" type="textarea" name="个人简介" br />
        <sa-item name="" br class="s-ok">
          <el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
        </sa-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import sa from '@/sa-frame/sa';


export default {
  name: 'bus-user-add',
  props: { param: Object },
  data() {
    return {
      // 超级对象
      m: this.createModel(),
      dims: this.param.dims,
    }
  },
  created: function () {
  },
  methods: {
    createModel() {
      return {
      }
    },
    // 变更
    ok: function () {
      // 表单校验
      let m = this.m;
      sa.checkNull(m.nickName, '请输入用户昵称！');
      sa.checkNull(m.nickName, '请输入用户名！');
      sa.checkNull(m.phone, '请输入联系方式！');
      sa.checkNull(m.pwd, '请输入密码！');
      sa.check(m.pwd.length < 6, '密码至少6位！');
      sa.check(m.surePwd !== m.pwd, '密码不一致！');
      sa.checkNull(m.status, '请确认状态！');
      sa.check(m.phone.length > 11, '联系方式超出范围！');

      // 添加
      sa.ajax('/scs/user/add', m, function (res) {
        sa.alert(res.msg, function () {
          this.m = this.createModel();
          sa.closeModel();
          sa.currView().f5();
        }.bind(this));
      }.bind(this));
    }
  }
}
</script>

<style scoped></style>
